#ifndef GISO_LOGGER_H
#define GISO_LOGGER_H

#include <spdlog/spdlog.h>
#include <spdlog/async.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/rotating_file_sink.h>

#include <memory>

namespace GiSo {

    class Logger {
    public:
        enum class OutputType {
            Console,
            File,
            Both
        };

        struct Options {
            OutputType outputType = OutputType::Console;
            std::string filename = "logfile.txt";
            size_t maxFileSize = 1024 * 1024 * 5; // 5MB
            int maxFiles = 3;
            ::spdlog::level::level_enum level = ::spdlog::level::info;
        };

        static void init(const Options& options);
        static std::shared_ptr<::spdlog::logger> getLogger();

        // Log macros
        #define GS_TRACE(msg, ...) GiSo::Logger::getLogger()->trace(msg, ##__VA_ARGS__)
        #define GS_DEBUG(msg, ...) GiSo::Logger::getLogger()->debug(msg, ##__VA_ARGS__)
        #define GS_INFO(msg, ...) GiSo::Logger::getLogger()->info(msg, ##__VA_ARGS__)
        #define GS_WARN(msg, ...) GiSo::Logger::getLogger()->warn(msg, ##__VA_ARGS__)
        #define GS_ERROR(msg, ...) GiSo::Logger::getLogger()->error(msg, ##__VA_ARGS__)
        #define GS_CRITICAL(msg, ...) GiSo::Logger::getLogger()->critical(msg, ##__VA_ARGS__)

        // #define GS_TRACE(msg, ...) 
        // #define GS_DEBUG(msg, ...) 
        // #define GS_INFO(msg, ...) 
        // #define GS_WARN(msg, ...) 
        // #define GS_ERROR(msg, ...) 
        // #define GS_CRITICAL(msg, ...)

    private:
        static std::shared_ptr<::spdlog::logger> m_logger;
    };

} // namespace GiSo

#endif